package com.sunzm.flink.datastream.scala.operator

import org.apache.flink.streaming.api.scala.{DataStream, StreamExecutionEnvironment, _}
import org.slf4j.{Logger, LoggerFactory}


object ScalaUnionDemo {
  private val logger: Logger = LoggerFactory.getLogger(this.getClass.getName.stripSuffix("$"))
  private val isLocal = true

  def main(args: Array[String]): Unit = {
    //1.创建执行的环境
    val env: StreamExecutionEnvironment = if (isLocal) {
      StreamExecutionEnvironment.createLocalEnvironmentWithWebUI()
    } else {
      StreamExecutionEnvironment.getExecutionEnvironment
    }

    val ds1: DataStream[Int] = env.fromElements(1, 3, 5)
    val ds2: DataStream[Int] = env.fromElements(2, 4, 6)

    //把ds1的数据和ds2的数据合并在一起
    val unionDS: DataStream[Int] = ds1.union(ds2)

    unionDS.print()

    //5.执行
    env.execute(this.getClass.getSimpleName.stripSuffix("$"))
  }
}
